from rest_framework import serializers
from .models import Orders, OrderGoods


class OrderGoodsSer(serializers.ModelSerializer):
    "订单商品序列化器"
    # name = serializers.SerializerMethodField(read_only=True)
    # img = serializers.SerializerMethodField(read_only=True)
    #
    # def get_img(self, obj):
    #     return  obj.goods.img
    #
    # def get_name(self, obj):
    #     return obj.goods.sku_name
    # price = serializers.SerializerMethodField(read_only=True)
    # def get_price(self,obj):
    #     return obj.good.selling_price
    # order_id = serializers.SerializerMethodField(read_only=True)
    # created_time = serializers.SerializerMethodField(read_only=True)
    # def get_created_time(self,obj):
    #     return obj.order.created_time()
    # def get_order_id(self,obj):
    #     return obj.order.order_id

    class Meta:
        model = OrderGoods
        # fields = ['id','count','price','order_id','created_time']
        fields = "__all__"
        # 深度未1
        depth = 1
